home *** CD-ROM | disk | FTP | other *** search
- /*
-
- xmodem1.c
-
-
- 8/1/85
-
-
- A version of Ward Christensen's MODEM program modified
- by Larry Jordan Associates to include XMODEM features
- and to provide compatibility with TCOMM.
-
- This file contains the main Xmodem functions.
-
-
- Copyright (c) 1984, 1985 Larry Jordan Associates
- */
-
-
-
- #include <stdio.h> /* Lattice header */
- #include <gleafs.h> /* Greenleaf header */
- #include <ibmkeys.h> /* Greenleaf header */
- #include <asic.h> /* Greenleaf header */
- #include <timedate.h> /* Greenleaf header */
- #include <disk.h> /* Greenleaf header */
- #include <protocol.h> /* Xmodem header provided on disk */
- #include <function.h> /* Xmodem header provided on disk */
- #include <xfer.h> /* Xmodem header provided on disk */
- #include <ibmpcio.h> /* Xmodem header provided on disk */
-
-
- char packet[134];
- char xmode,xdirfile[60],xfilenam[60];
- char kparity[10];
- char *comparms,portnum[60],*menudrv;
- char recvbuff[512],txbuff[512];
- char retstr[80],filedate[80];
-
- long strtout,timelog;
- long fbytes,fblocks;
- long xfertime;
- long goodbyte;
-
- float xfactor = 1.0;
-
- int cfgcolor,display,local,defsec,len,graphics;
- int monitor,cleared,attrib;
- int duplex,crtecho,portsel,
- port,bps,parity,wordlen,stopbits,comport;
-
-
-
- /* Copyright (c) 1984, 1985 Larry Jordan Associates */
-
-
- /*
- * main
- *
- *
- *
- */
-
- main()
- {
- extern int wordlen;
- char message[80];
-
- if (xferread() == FALSE || (makebuff() == ERROR)) /* if not file xfer info on disk or cannot make comm buffer, exit */
- {
- endxm();
- }
- if ( wordlen == 7) /* if not 8 data bits, tell user nono and exit */
- {
- stccpy(message,XBIT,79);
- prosay(23,0,message);
- asiputc(port,CR);
- asiputc(port,LF);
- asiputs(port,message);
- asiputc(port,CR);
- asiputc(port,LF);
- asiputc(port,CR);
- asiputc(port,LF);
- delay(30);
- endxm();
- }
- xmodem(); /* looks good so far, lets do it! */
- endxm(); /* shut down Xmodem buffer and go back */
- }
-
-
-
-
- int xmodem()
- {
- extern char xmode,xdirfile[60],xfilenam[60];
- char vline[120]; /* debug only */
-
- switch (xmode)
- {
-
- case 's':
- sxmodem(xdirfile); /* send file */
- break;
-
- case 'r':
- prouinfo(xdirfile,"Xmodem",128); /* display file upload info */
- rxmodem(xdirfile); /* receive file */
- break;
- default:
- return(ERROR); /* if you don't tell me what to do, I will just go home */
- }
- return(TRUE); /* we've finsihed this one */
- }
-
-
-
- /*
- * sxmodem
- *
- * send a file to the caller
- *
- *
- *
- */
-
- int sxmodem(dirfile)
- char *dirfile;
- {
-
- extern long int strtout,timelog;
- extern long fbytes,fblocks;
- extern long goodbyte;
- extern char retstr[80],packet[134];
- extern int port;
- char sector[SECSIZE], chrhldr[10];
- char vline[120],sechar,oldpack[134];
- int first;
- int foo;
- int rtrn,i;
- int timeout;
- int index, errorcnt,checksum,errortot;
- char blockcnt;
- int sectot;
- int percent;
- long totbyte;
-
- int eoxmfile = FALSE;
- int endfile = FALSE;
-
-
- if((foo = open(dirfile,0x8000)) == -1) /* open for read only */
- {
- close(foo);
- return(FALSE);
- }
- prodinfo(dirfile,foo,"Xmodem",128); /* display download info */
-
- errorcnt = 0;
- errortot = 0;
- blockcnt = 1;
- sectot = 1;
- goodbyte = 0L;
- totbyte = 0L;
-
- timeout=SENTIMOUT;
- clearmsg();
- prosay(19,23,"Holding for start ");
-
- eatbuf(); /* flush serial port of garbage */
-
- strtout = totsec(); /* set start time */
- while(TRUE)
- {
- if((rtrn = readbyte(30)) != TIMEOUT) /* wait for caller's NAK */
- {
- if(retstr[0] == NAK)
- {
- clearmsg();
- prosay(19,23,"Transfer initiated ");
- break;
- }
- else if (retstr[0] == CTRLX) /* caller wants abort? */
- {
- endtalk(foo,2);
- return(FALSE);
- }
- else if (rtrn == ESC) /* SYSOP wants abort? */
- {
- endtalk(foo,1);
- return(ERROR);
- }
- else
- {
- ++errorcnt;
- if( !(errorcnt % 3 )) clearmsg();
- if (errorcnt == MAXERRORS)
- {
- endtalk(foo,4);
- return(ERROR);
- }
- }
- }
- if (toolong(timeout)) /* caller waited too long, end Xmodem */
- {
- endtalk(foo,5);
- return(FALSE);
- }
- if (!carrier()) /* watch for that modem carrier */
- {
- close(foo);
- return(ERROR);
- }
- if (asikbhit()) /* did SYSOP hit key? */
- {
- if ( getch() == ESC )
- {
- clearmsg();
- endtalk(foo,1);
- return(ERROR);
- }
- }
- }
-
- sechar = sectot & 255;
-
- eoxmfile = makepack(foo,sechar); /* create first packet */
-
- while(TRUE) /* outside while for new block */
- {
-
- errorcnt = 0;
-
- clearmsg();
-
- if (eoxmfile == 0) break; /* no more bytes */
-
- if (eoxmfile < 128) endfile = TRUE; /* a few more bytes */
-
- for(i = 0; i < 134; i++)
- oldpack[i] = packet[i];
-
- first = TRUE;
-
- totbyte = goodbyte;
-
- eatbuf(); /* flush garabage */
-
- while (TRUE) /* inside while for current block */
- {
- if (asikbhit()) /* always let SYSOP get out */
- {
- if ( getch() == ESC)
- {
- endtalk(foo,1);
- return(ERROR);
- }
- }
-
- sprintf(vline,"Sending block # %d ",sectot);
- prosay(19,23,vline); /* tell SYSOP where we are */
-
- if (strput(oldpack) == TRUE) /* send packet to caller */
- {
- if (first && !endfile) /* first time around for this packet */
- {
- sechar = (sectot+1) & 255;
- eoxmfile = makepack(foo,sechar); /* create packet */
- first = FALSE;
- }
-
- while (!istxempty(port));
-
- eatbuf(); /* flush garabage */
-
- if((rtrn = readbyte(15)) == TIMEOUT) /* wait for caller response */
- {
- endtalk(foo,5);
- return(ERROR);
- }
- }
- if(retstr[0] == ACK) /* did Sam like packet? */
- {
- prosay(19,45,"- verified"); /* make SYSOP feel good */
- sprintf(vline,"%-4.4s","0 ");
- prosay(14,61,vline);
- sprintf(vline,"%d",sectot);
- prosay(12,61,vline);
- percent = (totbyte * 1.0)/fbytes * 100.0;
- sprintf(vline,"%-3d ",percent);
- prosay( 8,61,vline);
- sprintf(vline,"%ld",totbyte);
- prosay(10,61,vline);
- percent = (errortot * 1.0)/sectot * 100.0;
- if (percent > 100) percent = 100;
- sprintf(vline,"%-3d ",percent);
- prosay(16,61,vline);
- ++sectot;
- break;
- }
-
- else if (retstr[0] == CTRLX) /* caller wants abort? */
- {
- endtalk(foo,2);
- return(FALSE);
- }
-
- else if(rtrn == ESC) /* SYSOP wants abort? */
- {
- endtalk(foo,1);
- return(ERROR);
- }
-
- else if(!carrier()) /* did modem carrier drop? */
- {
- close(foo);
- return(ERROR);
- }
- else /* default is error--no need to check NAK */
- {
- prosay(19,45,"- transmission error"); /* caller said bad packet */
- ++errorcnt;
- ++errortot; /* we count that against you */
- sprintf(vline,"%d ",errorcnt);
- prosay(14,61,vline);
- sprintf(vline,"%d ",errortot);
- prosay(14,25,vline);
- percent = (errortot * 1.0)/sectot * 100.0;
- if (percent > 100) percent = 100;
- sprintf(vline,"%-3d ",percent);
- prosay(16,61,vline);
- prosay(16,25,"Receiver");
- clearmsg();
- if(errorcnt > MAXERRORS)
- {
- endtalk(foo,4);
- return(ERROR);
- }
- delay(10); /* delay .1 sec */
- eatbuf(); /* flush garabage */
- }
- } /* end of inside while */
-
- if(endfile) break; /* looks like the end */
-
- } /* end of outside while */
-
- close(foo);
- errorcnt = 0;
-
- clearmsg();
-
- while (TRUE)
- {
- clearmsg();
- prosay(19,23,"Sending EOT ");
- chrput(EOT); /* send Xmodem end of file mark */
- eatbuf();
- if((rtrn = readbyte(15)) == TIMEOUT )
- {
- chrput(CAN); /* caller did not respond, cancel xfer */
- clearmsg();
- prosay(19,23,ABORTF);
- prosay(19,40,ABORTEOF);
- return(ERROR);
- }
- else if (rtrn == ESC) return(ERROR); /* SYSOP could not wait and aborted? */
- if(retstr[0] == ACK) /* did Sam get that EOF? */
- {
- prosay(19,33," - verified");
- break;
- }
- if(!carrier())
- {
- return(ERROR);
- }
- ++errorcnt;
- if(errorcnt > MAXERRORS)
- {
- clearmsg();
- prosay(19,23," ** Transmission improperly completed");
-
- endtalk(foo,4);
- return(ERROR);
- }
- prosay(19,33," - acknowledge error");
-
- }
- clearmsg();
- prosay(19,23,"Transmission completed properly");
-
- sizewrit(dirfile,goodbyte);
-
- return(TRUE);
-
- }
-
-
- /*
- * makepack()
- *
- * make the next Xmodem packet to send
- *
- * Returns: TRUE if end of file encountered during read
- * FALSE if not end of file read
- *
- */
- bool makepack(foo,blockcnt)
- int foo;
- char blockcnt;
- {
-
- extern char packet[134];
- extern long goodbyte;
- char sector[SECSIZE];
- int bytesget;
- int index,checksum,eoxmfile,n;
-
-
- packet[0] = SOH; /* here is our header */
- packet[1] = blockcnt; /* the block number */
- packet[2] = ~blockcnt; /* the block number compliment */
-
- checksum = 0;
-
- bytesget=read(foo,sector,128); /* get next 128 byte block from disk */
-
- goodbyte = goodbyte + (long)bytesget; /* how many do we have total */
-
- if (bytesget == 0) return(bytesget); /* end of file */
-
- if(bytesget < 128) /* if not enough for full packet, pad it to 128 with NULLs */
- {
- for (index = bytesget; index < 128; index++)
- {
- sector[index] = NULL;
- }
- }
-
- for (index = 0, n = 3; index < SECSIZE; index++, n++) /* make packet and calc checksum */
- {
- packet[n] = sector[index];
- checksum += packet[n];
- }
-
- checksum = checksum & 255; /* get rid of excess bits, only need 8 */
-
- packet[131] = checksum; /* map it into packet */
-
- packet[132] = '\0'; /* we need null end of string to stop roll out later */
-
- return(bytesget);
-
- }
-
-
- /*
- * rxmodem
- *
- * receive a file from caller
- *
- *
- *
- *
- */
-
- int rxmodem(dirfile)
- char *dirfile;
- {
-
- extern long int strtout,timelog;
- extern char retstr[80];
- extern long fbytes,fblocks;
- extern long goodbyte;
-
- char blockcnt, blockcom;
- char sector[SECSIZE], packet[XMSIZE];
- char vline[120];
-
- int index, sectot, errorcnt,checksum,errortot;
- int xrecfile;
- int rtrn;
- int timeout,blknumct;
- int n;
- int endofile;
- int percent;
-
- if ((xrecfile = creat(dirfile, 0x8002 )) == -1) /* open new file */
- {
- close(xrecfile);
- return(ERROR);
- }
-
- strtout = totsec(); /* set start time mark */
- timeout = 10;
- errorcnt = 0;
- errortot = 0;
- blknumct = 0;
- sectot = 1;
- blockcnt = 1;
- n = 0;
- goodbyte = 0L;
- endofile = FALSE;
-
- clearmsg();
- prosay(19,23,"Holding for start... ");
- while(TRUE)
- {
- if(miready()) break; /* if char arrives, go */
-
- if(toolong(timeout)) /* if timeout, send NAK */
- {
- chrput(NAK);
- eatbuf();
- strtout = totsec(); /* restart time mark */
- ++n;
- if (n > 10) /* if more than 10 NAKs, stop */
- {
- clearmsg();
- prosay(19,23,"Too many Xmodem time outs.");
- endtalk(xrecfile,4);
- return(ERROR);
- }
- }
-
- if(!carrier()) /* if carrier lost, end Xmodem */
- {
- close(xrecfile);
- return(ERROR);
- }
- if (asikbhit()) /* if keyboard hit, get it */
- {
- if ( getch() == ESC) /* if ESC, stop Xmodem */
- {
- endtalk(xrecfile,1);
- return(ERROR);
- }
- }
- }
- clearmsg();
- prosay(19,23,"Initiating transfer... ");
-
- curset(19,23,0);
-
- while (TRUE) /* start loop */
- {
- if (asikbhit()) /* always let SYSOP get out */
- {
- if ( getch() == ESC)
- {
- endtalk(xrecfile,1);
- return(ERROR);
- }
- }
- clearmsg();
- sprintf(vline,"Receiving block # %d ",sectot);
- prosay(19,23,vline); /* where are we */
- for (index = 0; index < XMSIZE; index++) /* roll'em */
- {
- if((rtrn = readbyte(10)) == TIMEOUT) /* get char */
- {
- clearmsg();
- sprintf(vline,"Timeout waiting for block element %d",index+1);
- prosay(19,23,vline);
- goto nakit;
- }
-
- else if(rtrn == ESC) /* check SYSOP wanting out */
- {
- endtalk(xrecfile,1);
- return(ERROR);
- }
-
- if(!carrier()) /* keep checking that modem carrier! */
- {
- close(xrecfile);
- return(ERROR);
- }
-
- else
- {
- packet[index] = retstr[0];
-
- if(index == 0 && retstr[0] == EOT) /* is it end of file */
- {
- prosay(19,45," - EOT");
- endofile = TRUE;
- break;
- }
-
- if(index == 0 && (retstr[0] == CTRLX)) /* is it a caller abort */
- {
- endtalk(xrecfile,2);
- return(ERROR);
- }
- }
- }
-
- if(endofile) break;
-
- else if (packet[0] != SOH) /* good packet always start with SOH */
- {
- prosay(19,45," - SOH error");
- sprintf(vline,"SOH ");
- prosay(16,25,vline);
- goto nakit; /* if bad packet, NAK it */
- }
-
- blockcom = ~packet[2]; /* block number compliment */
-
- if (packet[1] != blockcom)
- {
- prosay(19,45," - Block number compliment error");
- sprintf(vline,"Block # ");
- prosay(16,25,vline);
- goto nakit;
- }
-
- else if (packet[1] != blockcnt) /* are we out of sequence */
- {
- prosay(19,45," - Wrong block number");
- sprintf(vline,"Block # ");
- prosay(16,25,vline);
- ++blknumct;
- goto nakit;
- }
- blknumct = 0;
- checksum = 0;
-
- for (index = 3, n = 0; n < SECSIZE; index++, n++) /* roll our own checksum calc */
- {
- sector[n] = packet[index];
- checksum += sector[n];
- }
-
- checksum = checksum & 255; /* throw away excess bits, only lower 8 count */
-
- if (checksum != packet[131]) /* was there an error in packet xfer */
- {
- prosay(19,45," - Checksum error");
- sprintf(vline,"Checksum ");
- prosay(16,25,vline);
- goto nakit; /* packet looks bad, do it over Sam */
- }
-
- chrput(ACK); /* tell Sam we are ready for next blast */
- eatbuf(); /* lets clean the tubes for next packet */
-
- if((write(xrecfile, sector, SECSIZE)) == -1) /* looks good so write it */
- {
- close(xrecfile);
- return(ERROR);
- }
-
- prosay(19,45," - verified"); /* make SYSOP feel good */
- sprintf(vline,"%d",sectot);
- prosay(12,61,vline);
- sprintf(vline,"%-4.4s","0 ");
- prosay(14,61,vline);
- goodbyte = sectot * 128L;
- sprintf(vline,"%ld",goodbyte);
- prosay(10,61,vline);
- percent = (errortot * 1.0)/sectot * 100.0;
- sprintf(vline,"%-3d ",percent);
- prosay(16,61,vline);
-
- errorcnt = 0;
- blockcnt = ++sectot & 255; /* increment sector total and block count modulo 255 */
-
- clearmsg();
- continue; /* keep on rolling */
-
- nakit: /* I hate'em too but sometimes... */
-
- if(!carrier()) /* is Sam still there? */
- {
- close(xrecfile);
- return(ERROR);
- }
- else if(++errorcnt > MAXERRORS) /* has Sam got a bad telephone line? */
- {
- endtalk(xrecfile,4); /* looks bad, so save him the possible bad xfer */
- return(ERROR);
- }
- else
- {
- while( miready() ) /* if chars still coming */
- {
- if (!carrier()) break;
- delay(30); /* wait .5 sec */
- eatbuf(); /* eat buffer before retest */
- }
- if (blknumct == 3 && (packet[1] == blockcnt - 1) ) chrput(ACK); /* in case ACK was clobbered for a good block */
- else chrput(NAK); /* don't mince words, tell him it was no good */
- eatbuf(); /* eat buffer before retest */
- ++errortot; /* we count this one against you Sam */
- sprintf(vline,"%d ",errorcnt);
- prosay(14,61,vline);
- sprintf(vline,"%d ",errortot); /* tell SYSOP how bad it is */
- prosay(14,25,vline);
- percent = (errortot * 1.0)/sectot * 100.0;
- sprintf(vline,"%-3d ",percent);
- prosay(16,61,vline);
- clearmsg();
- }
- }
-
- close(xrecfile);
-
- chrput(ACK); /* tell the other end we accepted his EOT */
- chrput(ACK);
- chrput(ACK); /* make sure he got it */
-
- clearmsg();
- prosay(19,23,GOTITOK); /* make SYSOP feel real good */
-
- sizewrit(dirfile,goodbyte); /* create data TCOMM needs to record this xfer in log */
-
- return(TRUE);
-
- }
-
-
-
- /*
- * endtalk
- *
- *
- * abornmal file transfer end, xfer terminate, send message to screen
- */
- int endtalk(fpxfer,why)
- int fpxfer;
- int why;
- {
-
- close(fpxfer); /* close file being transferred */
-
- chrput(CAN); /* send Xmodem cancel to caller */
- eatbuf(); /* eat any chars coming from caller */
- clearmsg(); /* get ready to give message */
- if(why != 0) /* 0 - normal end */
- {
- prosay(19,23,ABORTF);
- }
- if(why == 1) prosay(19,40,ABORTSYS); /* 1 - Operator abort */
- if(why == 2) prosay(19,40,ABORTUSR); /* 2 - User abort */
- if(why == 3) prosay(19,40,ABORTEOF); /* 3 - end of file */
- if(why == 4) prosay(19,40,ABORTXER); /* 4 - Xmodem errors */
- if(why == 5) prosay(19,40,ABORTTO); /* 5 - timeout */
- chrput(CAN); /* send Xmodem cancel to caller */
-
- }
-
-
- /*
- * prodinfo
- *
- * protocol file transfer information for report screen
- * and send tty copy to caller before xfer starts
- *
- *
- */
- bool prodinfo(dirfile,foo,protocol,blocklen)
- char *dirfile,*protocol;
- int blocklen,foo;
- {
-
-
- extern int bps,timerem,port;
- extern long xfertime;
- extern long fbytes,fblocks;
- extern char filedate[];
-
- float decblks;
- char vline[RECSIZE];
-
- long xfermins,xfersecs;
- double blkfrac;
- float xferminf;
-
- xfermins = 0;
- xfersecs = 0;
- fbytes = 0;
- fblocks = 0;
-
- fbytes = lseek(foo,0L,2); /* get file size */
- lseek(foo,0L,0); /* go back to start of file */
-
- decblks = (float) (fbytes)/blocklen * 1.0 + 0.5; /* how many blocks */
- fblocks = decblks;
-
- asiputc(port,CR);
- asiputc(port,LF);
-
- sprintf (vline,"Total protocol blocks: %ld",fblocks);
- asiputs(port,vline); /* tell caller */
-
- asiputc(port,CR);
- asiputc(port,LF);
- asiputc(port,CR);
- asiputc(port,LF);
- asiputs(port,DNLMSG);
- asiputc(port,CR);
- asiputc(port,LF);
- asiputc(port,CR);
- asiputc(port,LF);
-
- /* now lets calculate an approximate xfer time based on imperical time tests */
- /* modify the 0.049 if you find your system gives different results */
-
- xfertime = fbytes * 0.049 * (300.0 / bps);
- if (xfertime < 1) xfertime = 1L; /* something is wrong */
- xfermins = xfertime/60;
- xferminf = xfertime/60.0;
- xfersecs = xfertime - xfermins * 60;
-
- protrept();
-
- fdate(dirfile,filedate);
- prosay( 2,25,dirfile);
- prosay( 3,25,filedate);
- prosay( 6,25,"Xmodem");
- sprintf (vline,"%-d %-s",blocklen,"bytes");
- prosay( 6,61,vline);
- sprintf (vline,"%-3.2f %-s",xferminf,"min.");
- prosay( 8,25,vline);
- sprintf (vline,"%-ld",fbytes);
- prosay(10,25,vline);
- sprintf (vline,"%ld",fblocks);
- prosay(12,25,vline);
- sprintf (vline,"%-4.4s","0 ");
- prosay(14,25,vline);
- prosay(14,61,vline);
- prosay(16,25,"None ");
-
- return(TRUE);
-
-
- }
-
-
- /*
- * prouinfo
- *
- * protocol upload info to fill report screen at xfer start
- *
- *
- */
- bool prouinfo(dirfile,protocol,blocklen)
- char *dirfile, *protocol;
- int blocklen;
- {
- extern int port;
-
- char vline[120];
-
- asiputc(port,CR);
- asiputc(port,LF);
-
- asiputs(port,UPLMSG);
-
- asiputc(port,CR);
- asiputc(port,LF);
- asiputc(port,CR);
- asiputc(port,LF);
-
- protrept();
-
- prosay( 2,25,dirfile);
-
- prosay( 6,25,"Xmodem");
- prosay( 6,61,"128 bytes");
- sprintf (vline,"%s","Unknown ");
- prosay( 3,25,vline);
- prosay( 8,25,vline);
- prosay( 8,61,vline);
- prosay(10,25,vline);
- prosay(12,25,vline);
- sprintf (vline,"%-4.4s","0 ");
- prosay(14,25,vline);
- prosay(14,61,vline);
- prosay(16,25,"None ");
-
- return(TRUE);
-
- }
-
-
-
-
-
- /*
- * protrept
- *
- *
- * protocol progress report screen blank
- *
- */
- protrept()
- {
- extern int display;
-
- if(!display) return; /* display is off, so don't show screen */
-
- curtype(BLANK,6,7);
- prosay( 0,0," FILE TRANSFER PROGRESS REPORT ");
- prosay( 1,0," …ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª ");
- if ( xmode == 's') {
- prosay( 2,0," ∫ Sending file: ∫ ");
- } else {
- prosay( 2,0," ∫ Receiving file: ∫ ");
- }
-
- prosay( 3,0," ∫ Created or updated: ∫ ");
- prosay( 4,0," ÃÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕπ ");
- prosay( 5,0," ∫ ∫ ");
- prosay( 6,0," ∫ Selected protocol: Protocol packet size: ∫ ");
- prosay( 7,0," ∫ ∫ ");
- prosay( 8,0," ∫ Transfer time: Percent transferred: ∫ ");
- prosay( 9,0," ∫ ∫ ");
- prosay(10,0," ∫ File size (bytes): Bytes transferred: ∫ ");
- prosay(11,0," ∫ ∫ ");
- prosay(12,0," ∫ Total file packets: Packets transferred: ∫ ");
- prosay(13,0," ∫ ∫ ");
- prosay(14,0," ∫ Total packet errors: Errors this packet: ∫ ");
- prosay(15,0," ∫ ∫ ");
- prosay(16,0," ∫ Last error type: Percent packet errors: ∫ ");
- prosay(17,0," ∫ ∫ ");
- prosay(18,0," ÃÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕπ ");
- prosay(19,0," ∫ Protocol message: ∫ ");
- prosay(20,0," ÃÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕπ ");
- prosay(21,0," ∫ The System Operator can press ESC to abort the file transfer. ∫ ");
- prosay(22,0," »ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº ");
- prosay(23,0," ");
- curset(2,17,0);
-
- }
-
-
-
-
- /*
- * clearmsg
- *
- * clear protocol message on progress screen
- *
- */
- int clearmsg()
- {
- prosay(19,23," ");
-
- }
-
-
- /*
- * xferread()
- *
- * read file transfer information from default drive/directory
- * for protocol use
- *
- * xmode: r = receive from caller
- * s = send file to caller
- * xfilenam: filename without directory path or drive for display only
- * xdirfile: path and name of file to transfer (i.e., c:\files\filename)
- * protocols that accept wildcards should accept and expand
- * the filename in this protocol somewhere
- * portnum: 1 = COM1 (the selected one is initialized - just start
- * 2 = COM2 communicating with it)
- * bps = communications speed in bits per second to calculate xfer time
- * parity = parity of communications line (Xmodem only allows n - none)
- * display: 0 = display is off and no information should be sent to screen
- * 1 = display is on and info should be sent to screen
- * cfgcolor = foreground color in caller mode
- * set in TCOMM configuration profile
- *
- * Returns: FALSE if file error
- * TRUE if all ok
- */
- int xferread()
- {
-
- extern char xmode,xdirfile[60],xfilenam[60],kparity[10];
- extern int display,cfgcolor,wordlen,port,parity,bps;
-
- FILE *fpstat;
-
-
- if((fpstat=fopen(FILEXFER,"r"))==NULL)
- {
- clrerr(fpstat);
- return(FALSE);
- }
- if((fscanf(fpstat,"%c %s %s %d %s %d %d",&xmode,xdirfile,portnum,&bps,kparity,&display,&cfgcolor)) != 7)
- {
- fclose(fpstat);
- clrerr(fpstat);
- return(FALSE);
-
- }
- if((fclose(fpstat))==ERROR)
- {
- clrerr(fpstat);
- return(FALSE);
- }
- if(portnum[3] == '2') port = 1;
- else port = 0;
-
- if (kparity[0] == 'n')
- {
- parity = NONE;
- wordlen = 8;
- stopbits = 1;
- }
- else
- {
- wordlen = 7;
- stopbits = 1;
- if (kparity[0] == 'e') parity = EVEN;
- if (kparity[0] == 'o') parity = ODD;
- }
-
- unlink(FILEXFER);
- return(TRUE);
-
- }
-
-
-
- /*
- * sizewrit(dirfile,bytes)
- *
- * write filename and bytes of file transfer to default drive/directory
- * for main program to pickup
- *
- * dirfile: filename preceeded by path
- *
- * bytes: 0 if file transfer abort
- * # if transfer success
- *
- * Returns: FALSE if file error
- * TRUE if all ok
- */
- int sizewrit(dirfile,bytes)
- char *dirfile;
- long bytes;
- {
-
- FILE *fpstat;
-
-
- if((fpstat=fopen(FILESIZE,"w"))==NULL)
- {
- clrerr(fpstat);
- return(FALSE);
- }
- fprintf(fpstat,"%s %7ld -%c",dirfile,bytes,CR); /* use - for date */
- if((fclose(fpstat))==ERROR)
- {
- clrerr(fpstat);
- }
-
- return(TRUE);
-
-
- }
-
-
-
- /*
- * F D A T E
- *
- * Return file creation date/time
- *
- *
- */
- fdate(fname,str)
- char *fname,*str;
- {
-
- struct TIMEDATE td; /* Greenleaf function */
-
- if (( getfstamp( &td,fname)) != 0) return(0); /* return false if not */
- /* able to get file date */
-
- sprintf(str,"%02.2d/%02.2d/%-4d - %002.2d:%002.2d",
- td.month,td.day,td.year,td.hours,td.minutes);
- return(1);
-
- }